//
//  DengerousViewModel.m
//  HonlivApp
//
//  Created by admin on 2017/6/25.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "DengerousViewModel.h"
#import "DengerousFrame.h"
#import "DengerousModel.h"

@interface DengerousViewModel ()

@property (nonatomic,strong) NSDictionary *dic;

@end

@implementation DengerousViewModel

-(instancetype)initWithType:(DengerousType)type date:(NSString *)date doctor:(NSString *)doctor department:(NSString *)depart page:(NSInteger)page{
    //{db:"OracleString",SqlNo:"22",发布时间:"2017-06-05",科室:"010321",处理医生:"王展鹏",Page:"1"}
    //{db:"OracleString",SqlNo:"25",发布时间:"2017-04-14",科室:"010311",Page:"1"}
    NSString *pageNum = [NSString stringWithFormat:@"%ld",page];
    if (type == DengerousTypePersonal) {
        _dic = @{@"db":@"OracleString",@"SqlNo":@"22",@"发布时间":date,@"科室":depart,@"处理医生":doctor,@"Page":pageNum};
    }else{
        _dic = @{@"db":@"OracleString",@"SqlNo":@"25",@"发布时间":date,@"科室":depart,@"处理医生":doctor,@"Page":pageNum};
    }
    return [self init];
}
-(void)getDengerousInfoSuccess:(void (^)(NSArray *))completion{
    NSString *url = [NSString stringWithFormat:@"%@%@",HOSPITAL_URL,COMMON_URL];
    [NetWorker getCommonDatasWithURLStr:url body:_dic success:^(id result) {
        NSArray *arr = [JsonHelper arrayWithJsonString:result[@"Entity"]];
        NSMutableArray *modelArr = [NSMutableArray array];
        for (NSDictionary *dic in arr) {
            DengerousModel *model = [DengerousModel yy_modelWithDictionary:dic];
            DengerousFrame *dengerF = [[DengerousFrame alloc] init];
            dengerF.dengerous = model;
            [modelArr addObject:dengerF];
        }
        completion(modelArr);
    } failure:^(id result) {
        completion([NSArray array]);
    }];

}


@end
